from django.db import models
from django.contrib.auth.models import AbstractUser


# Create your models here.
from django.utils import timezone

# 会员表
class VipUser(models.Model):
    title = models.CharField('vip名称', max_length=16)
    level = models.CharField('vip等级', max_length=16)
    desc = models.CharField('vip特权描述', max_length=160)

    class Meta:
        db_table = 'tb_vipuser'

    def __str__(self):

        return self.title


class User(AbstractUser):
    phone = models.CharField('手机号', max_length=15)
    img = models.ImageField(upload_to='user', null=True)
    nick_name = models.CharField('昵称', max_length=20, null=True)
    adress = models.CharField('地址', max_length=100, null=True)
    vip = models.ForeignKey(VipUser, on_delete=models.CASCADE, null=True)
    vip_date = models.DateTimeField(default=timezone.now, null=True)

    class Meta:
        db_table = 'tb_user'
